# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/19 下午6:28
 @Author  : tgy
 利用一些规则从中提取出需要的值或者是缩短序列
"""

def lg(val):
    return val > 2

def test01():
    ...
    nums = [1, 3, 4, 2, 2]
    print([n for n in nums if n > 2])
    print(list(filter(lg, nums)))


def test02():
    mylist = [1, 4, -5, 10, -7, 2, 3, -1]
    print([n if n >= 0 else 0 for n in mylist])


if __name__ == '__main__':
    ...
    test02()
